#include <bits/stdc++.h>
// 2025/05/17
// tag: Persistent segment tree
// Author: Forever
using namespace std;
using int64 = int64_t;

#define MAXN 2001

class PST {
private:
    class Segmenttree {
    public:
        int lc, rc, sum;
    };
    Segmenttree tr[MAXN * 32];
    int idx, now, len, root[MAXN];
    int build(int l, int r){
        int x = ++idx;
        tr[x].sum = 0;
        if (l == r)
            return x;
        int mid = (l + r) >> 1;
        tr[x].lc = build(l, mid), tr[x].rc = build(mid + 1, r);
        return x;
    }
    int insert(int cur, int l, int r, int x, int s){
        int k = ++idx;
        tr[k] = tr[cur];
        if (l == r) {
            tr[k].sum += s;
            return k;
        }
        int mid = (l + r) >> 1;
        if (x <= mid)
            tr[k].lc = insert(tr[k].lc, l, mid, x, s);
        else
            tr[k].rc = insert(tr[k].rc, mid + 1, r, x, s);
        tr[k].sum = tr[tr[k].lc].sum + tr[tr[k].rc].sum;
        return k;
    }
    int query(int p, int q, int l, int r, int k){
        if (l == r)
            return l;
        int mid = (l + r) >> 1, opt = tr[tr[q].lc].sum - tr[tr[p].lc].sum;
        if (k <= opt)
            return query(tr[p].lc, tr[q].lc, l, mid, k);
        else
            return query(tr[p].rc, tr[q].rc, mid + 1, r, k - opt);
    }
public:
    PST(int l) { idx = 0, len = l; root[0] = build(1, len);  }
    void insert(int x, int s){
        root[++now] = insert(root[now], 1, len, x, s);
    }
    int query(int l, int r, int k){
        return query(root[l - 1], root[r], 1, len, k);
    }
};

int n, m, a[MAXN], ind[MAXN];

int main()
{
    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    memcpy(ind, a, sizeof(ind));
    sort(ind + 1, ind + n + 1);
    int len = unique(ind + 1, ind + n + 1) - ind - 1;
    PST rt(len);
    for (int i = 1; i <= n; ++i)
        rt.insert(lower_bound(ind + 1, ind + len + 1, a[i]) - ind, 1);
    for (int i = 1; i <= m; i++) {
        int l, r, k;
        cin >> l >> r >> k;
        printf("%d\n", ind[rt.query(l, r, k)]);
    }
    return 0;
}